from time import time
P.<x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11> = PolynomialRing(QQ,order='deglex')

def test_katsura(N1,N2):
  for n in range(N1,N2):
    if n < 3:
      continue
    I = sage.rings.ideal.Katsura(P,n)
    t0 = time()
    g = I.groebner_basis()
    t1 = time()
    s = open('out/k%d' % n).read()
    gr = sage_eval(s, globals())
    assert g == gr
    print 'k%d ok %.2f' % (n,t1-t0)

def test_cyclic(N1,N2):
  for n in range(N1,N2):
    if n < 3:
      continue
    I = sage.rings.ideal.Cyclic(P,n)
    t0 = time()
    g = I.groebner_basis()
    #print g
    t1 = time()
    s = open('out/cy%d' % n).read()
    gr = sage_eval(s, globals())
    assert g == gr
    print 'cy%d ok %.2f' % (n,t1-t0)

def test_mora(N):
  for n in range(3,N,10):
    if n < 3:
      continue
    I = Ideal([x0^(n+1) - x1*x2^(n-1)*x3, x0*x1^(n-1) - x2^n, x0^n*x2-x1^n*x3])
    t0 = time()
    g = I.groebner_basis()
    #print g
    t1 = time()
    s = open('out/m%d' % n).read()
    gr = sage_eval(s, globals())
    assert g == gr
    print 'm%d ok %.2f' % (n,t1-t0)


test_katsura(3,7)
test_cyclic(3,6)
test_mora(50)
